﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace SPMonkey.Core
{
    public static class Utilities
    {
        public static string UnCamel(string camelcase)
        {
            return System.Text.RegularExpressions.Regex.Replace(camelcase, "([A-Z])", " $1", System.Text.RegularExpressions.RegexOptions.Compiled).Trim();
        }
    }
    public static class UtilityExtension
    {
        public static readonly Regex guidRegEx = new Regex(@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$");

        public static bool IsGuid(this string expression)
        {
            if (!String.IsNullOrEmpty(expression))
            {
                return guidRegEx.IsMatch(expression);
            }
            return false;
        }

        public static void Append<T>(this StringBuilder sb, params T[] args)
        {
            sb.Append(args);
        }

        public static void Append<T>(this StringBuilder sb, IEnumerable<T> args)
        {
            foreach (var val in args)
            {
                sb.Append(val);
            }
        }
    }
}
